home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
- * *
- * Copyright (c) 1991 Silicon Graphics, Inc. *
- * All Rights Reserved *
- * *
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
- * *
- * The copyright notice above does not evidence any actual of intended *
- * publication of such source code, and is an unpublished work by Silicon *
- * Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
- * the property of Silicon Graphics, Inc. Any use, duplication or *
- * disclosure not specifically authorized by Silicon Graphics is strictly *
- * prohibited. *
- * *
- * RESTRICTED RIGHTS LEGEND: *
- * *
- * Use, duplication or disclosure by the Government is subject to *
- * restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
- * Technical Data and Computer Software clause at DFARS 52.227-7013, *
- * and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
- * Supplement. Unpublished - rights reserved under the Copyright Laws of *
- * the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
- * Shoreline Blvd., Mountain View, CA 94039-7311 *
- **************************************************************************
- *
- * File: settings.c
- *
- * Description: Displays the job and printer options for the specified
- * printer.
- *
- **************************************************************************/
-
-
- #ident "$Revision: 1.3 $"
-
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #ifdef sgi
- #include <getopt.h>
- #endif
- #include "spool.h"
-
-
- char *pname;
- int spooler = SL_SPOOLER_NONE; /* Indicate that no spooler is set */
- int not_sysv = 0;
-
-
- extern char *optarg;
- extern int optind;
-
-
- void disp_settings(SLSettingsStruct*, SLSysVSpoolerOptionsStruct*, char*);
- void usage(char*);
-
-
- main(int argc, char *argv[])
- {
- int ch, ret;
- int errflag = 0;
- SLSettingsStruct *settings; /* SLGetPrinterSettings(3) */
- SLSysVSpoolerOptionsStruct *spooler_opts; /* SLSysVGetSpoolerOptions(3) */
- char *printer_opts; /* SLSYSVGetPrinterOptions(3) */
-
- /*
- * Process command line args
- */
- while ((ch = getopt(argc, argv, "s:")) != -1) {
- switch (ch) {
- case 's': /* Spooler to use */
- if (!strcmp(optarg, "bsd"))
- spooler = SL_SPOOLER_BSD;
- else if (!strcmp(optarg, "sysv"))
- spooler = SL_SPOOLER_SYSV;
- else
- errflag++;
- break;
- case '?':
- default:
- errflag++;
- break;
- }
- }
-
- /*
- * If error, print usage and exit
- */
- if (errflag) {
- usage(argv[0]);
- exit(1);
- }
-
- /*
- * If a spooling system has been specified set it
- */
- if (spooler != SL_SPOOLER_NONE) {
- if (SLSetSpooler(spooler) < 0) {
- SLPerror(argv[0]);
- exit(1);
- }
- }
-
- /*
- * Get the printer name. If no printer name is specified, use
- * the default printer
- */
- if (argc == optind) {
- if (SLGetDefPrinterName(&pname) < 0) {
- SLPerror(argv[0]);
- exit(1);
- }
- } else
- pname = argv[optind];
-
- /*
- * Get the settings for this printer in a spooling
- * system independent format.
- */
- if (SLGetPrinterSettings(pname, &settings) < 0) {
- int j, status, nout;
- char **out_buf;
- SLPerror(argv[0]);
- if ((status = SLGetSpoolerError(&out_buf, &nout)) != 0) {
- (void)fprintf(stderr, "Spooler exit status: %d\n", status);
- (void)fprintf(stderr, "Spooler error message(s):\n");
- for (j = 0; j < nout; j++)
- (void)fprintf(stderr, "\t%s\n", out_buf[j]);
- }
- exit(1);
- }
-
- /*
- * Get the settings for this printer in a spooling
- * system dependent format.
- */
- ret = SLSysVGetSpoolerOptions(&spooler_opts);
- if (ret < 0 && SLerrno == SL_ERR_NO_SYSV)
- not_sysv = 1;
- else if (ret < 0) {
- int j, status, nout;
- char **out_buf;
- SLPerror(argv[0]);
- if ((status = SLGetSpoolerError(&out_buf, &nout)) != 0) {
- (void)fprintf(stderr, "Spooler exit status: %d\n", status);
- (void)fprintf(stderr, "Spooler error message(s):\n");
- for (j = 0; j < nout; j++)
- (void)fprintf(stderr, "\t%s\n", out_buf[j]);
- }
- exit(1);
- }
- if (not_sysv == 0) {
- if (SLSysVGetPrinterOptions(pname, &printer_opts) < 0) {
- int j, status, nout;
- char **out_buf;
- SLPerror(argv[0]);
- if ((status = SLGetSpoolerError(&out_buf, &nout)) != 0) {
- (void)fprintf(stderr, "Spooler exit status: %d\n", status);
- (void)fprintf(stderr, "Spooler error message(s):\n");
- for (j = 0; j < nout; j++)
- (void)fprintf(stderr, "\t%s\n", out_buf[j]);
- }
- exit(1);
- }
- }
-
- /*
- * Show the settings information
- */
- disp_settings(settings, spooler_opts, printer_opts);
-
- return 0;
- }
-
-
- void disp_settings(SLSettingsStruct *gptr, SLSysVSpoolerOptionsStruct *sptr,
- char *pptr)
- {
- (void)printf("Spooler independent settings for %s:\n", pname);
- (void)printf("\tJob handling:\t\t%s\n", (gptr->copy) ? "copy": "link");
- (void)printf("\tMail on completion:\t%s\n", (gptr->mail) ? "yes": "no");
- (void)printf("\tBanner title:\t\t%s\n", (gptr->title) ?
- gptr->title: "[default]");
- (void)printf("\tSpooler options:\t%s\n", (gptr->options) ?
- gptr->options: "[none]");
-
- if (not_sysv)
- return;
-
- (void)printf("\n");
- (void)printf("System V spooler settings for %s:\n", pname);
- (void)printf("\tJob handling:\t\t%s\n", (sptr->copy) ? "copy": "link");
- (void)printf("\tMail on completion:\t%s\n", (sptr->mail) ? "yes": "no");
- (void)printf("\tMessage on completion:\t%s\n",
- (sptr->message) ? "yes": "no");
- (void)printf("\tSuppress job ID:\t%s\n", (sptr->suppress_id) ? "yes": "no");
- (void)printf("\tBanner title:\t\t%s\n", (sptr->title) ?
- sptr->title: "[default]");
- (void)printf("\tPrinter options:\t%s\n", (pptr) ? pptr: "[none]");
- }
-
-
- void usage(char *progname)
- {
- (void)fprintf(stderr, "%s [-s bsd | sysv] [printer_name]\n",
- progname);
- }
-